home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#46 (Jul 89)
/
Basic Source
/
GETINDSTRING.S
next >
Wrap
Text File
|
1989-05-19
|
1KB
|
39 lines
'V
'S
'GETINDSTRING$ function By Charles Stricklin
'Modified by Dave Kelly for MacTutor, May, 1989
'This function is identical to the procedure GetIndString
'which is not in ROM and not supported by ZBasic. It reads
'a string from a string list and returns a copy of it in the
'variable the String$. If the string list doesn't exist of the
'index is out of range an empty string is returned.
' stringListID is the resource ID of the string list; it's resource type is 'STR#'.
' stringIndex is the index of the desired string within the list.
LONG FN GETINDSTRING$(StringListID, StringIndex)
TheString$=""
Offset=0
FALSE=0
MyHandle&=FN GETRESOURCE(CVI("STR#"),StringListID)
LONG IF FN RESERROR=FALSE
MyPointer&=USR 3(MyHandle&)
NumberOfStrings=PEEK WORD(MyPointer&)
LONG IF (StringIndex>0) AND (StringIndex <= NumberOfStrings)
LONG IF StringIndex>1
FOR ThisString=1 TO StringIndex-1
LengthOfThisString=PEEK(MyPointer&+2+Offset)
Offset=Offset+LengthOfThisString+1
NEXT
END IF
LengthOfDesiredString=PEEK(MyPointer&+2+Offset)
FOR Character=1 TO LengthOfDesiredString
TheString$=TheString$+CHR$(PEEK(MyPointer&+2+Offset+Character))
NEXT
END IF
MyHandle&=USR 7(MyPointer&)
CALL DETACHRESOURCE(MyHandle&)
END IF
END FN= TheString$